Skip to content

fix(antigravity): use global config directory for mcp_config.json#918

Open
moferrin wants to merge 20 commits into
Gentleman-Programming:mainfrom
moferrin:fix/antigravity-mcp-config-path
Open

fix(antigravity): use global config directory for mcp_config.json#918
moferrin wants to merge 20 commits into
Gentleman-Programming:mainfrom
moferrin:fix/antigravity-mcp-config-path

Conversation

@moferrin

@moferrin moferrin commented Jun 17, 2026

Copy link
Copy Markdown

🔗 Linked Issue

Closes #779

🏷️ PR Type

  • type:bug — Bug fix (non-breaking change that fixes an issue)
  • type:feature — New feature (non-breaking change that adds functionality)
  • type:docs — Documentation only
  • type:refactor — Code refactoring (no functional changes)
  • type:chore — Build, CI, or tooling changes
  • type:breaking-change — Breaking change

📝 Summary

Updates the Antigravity MCPConfigPath to point to the global config directory (~/.gemini/config/mcp_config.json) instead of the variant-specific path (~/.gemini/antigravity-cli/mcp_config.json).

Problem Context:
Antigravity enforces a configuration hierarchy where the global configuration file (~/.gemini/config/mcp_config.json) takes absolute priority. This global config file is automatically created by Antigravity when it is installed.

Because this global file exists (even if it is empty), Antigravity reads it, assumes its state, and completely ignores the CLI-specific file (~/.gemini/antigravity-cli/mcp_config.json) that Gentle AI just finished configuring.

As a result, Engram MCP tools are never injected into the session (tools like mem_save, mem_context, etc., do not appear as callable actions in the agent's toolset), forcing users to investigate why the MCP is unavailable even though the Engram CLI works perfectly.

Official Documentation Alignment:
This change perfectly aligns with the Antigravity MCP documentation which now explicitly specifies that the configuration file is located at ~/.gemini/config/mcp_config.json.

By making this change and writing the configuration directly to the shared global directory, we ensure that:

  1. MCP servers are injected correctly for all users right out of the box.
  2. Engram becomes available across the entire ecosystem, including the CLI, Antigravity Desktop, and the IDE extension.

📂 Changes

File / Area What Changed
internal/agents/antigravity/adapter.go Modified MCPConfigPath and OS-specific variant checks
internal/agents/antigravity/adapter_test.go Updated tests to expect the global config path and IDE paths
internal/components/engram/inject.go Removed hardcoded --tools=agent exception
internal/components/engram/inject_test.go Updated MCP injection expectations to the global path and tools profile
internal/components/golden_test.go Updated MCP config location checks

🧪 Test Plan

Unit Tests

go test ./...

E2E Tests (Docker required)

cd e2e && ./docker-test.sh
  • Unit tests pass (go test ./...)
  • E2E tests pass (cd e2e && ./docker-test.sh)
  • Manually tested locally

✅ Contributor Checklist

  • PR is linked to an issue with status:approved
  • PR stays within 400 changed lines, or I have requested/obtained maintainer-applied size:exception with rationale documented
  • I have added the appropriate type:* label to this PR
  • Unit tests pass (go test ./...)
  • E2E tests pass (cd e2e && ./docker-test.sh)
  • I have updated documentation if necessary
  • My commits follow Conventional Commits format
  • My commits do not include Co-Authored-By trailers

Summary by CodeRabbit

  • New Features

    • Antigravity now uses a shared Gemini MCP config location, making MCP settings consistent across app variants.
    • On supported systems, the app now picks the most appropriate IDE-specific configuration folder first, with sensible fallbacks.
  • Bug Fixes

    • Fixed MCP config writes so Antigravity and Engram now use the expected shared config path.
    • Updated MCP command options so agent tools are enabled consistently.
  • Documentation

    • Updated setup guidance to reflect the new shared configuration location.

Copilot AI review requested due to automatic review settings June 17, 2026 14:35
@coderabbitai

coderabbitai Bot commented Jun 17, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Antigravity MCP config writes now target the shared global Gemini config path. Variant directory resolution now prefers OS-specific IDE locations before desktop and CLI fallbacks. Engram injection now uses the default MCP tool args and updated tests reflect the new paths.

Changes

Antigravity MCP Config and Variant Resolution

Layer / File(s) Summary
Global MCP path and shared config use
internal/agents/antigravity/adapter.go, internal/agents/antigravity/adapter_test.go, internal/components/golden_test.go, docs/agents.md
Introduces GlobalMCPConfigPath, updates Adapter.MCPConfigPath to return ~/.gemini/config/mcp_config.json, and updates tests plus documentation to read from the shared location.
OS-aware variant directory lookup
internal/agents/antigravity/adapter.go, internal/agents/antigravity/adapter_test.go
antigravityVariantDir now checks OS-specific IDE directories first, then desktop and CLI fallbacks; adapter tests expand coverage for the new precedence and platform-specific paths.
Engram MCP overlay arguments
internal/components/engram/inject.go, internal/components/engram/inject_test.go
Removes the Antigravity-specific MCP args override and updates injection tests to expect the shared global config path and --tools=agent in the generated MCP config.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related issues

  • Gentleman-Programming/gentle-ai#917 — Also moves Antigravity MCP config lookup from the variant directory to the shared ~/.gemini/config/mcp_config.json path.

Suggested labels

type:bug, size:exception

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly states the main change to the Antigravity MCP config path.
Linked Issues check ✅ Passed The PR updates Antigravity to use the global MCP config path and restores the Engram --tools=agent profile across variants.
Out of Scope Changes check ✅ Passed The changes stay within the documented Antigravity path fix and Engram profile updates, with matching tests and docs.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Updates Antigravity MCP config handling to use a single shared global config file location, and aligns tests/golden assertions with the new path.

Changes:

  • Switch Antigravity MCPConfigPath from variant-specific directories to ~/.gemini/config/mcp_config.json.
  • Update golden test and injection tests to read/verify MCP config in the new global location.
  • Adjust adapter path tests to expect the shared MCP config path for both CLI-only and Desktop-only setups.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
internal/components/golden_test.go Updates golden test to read MCP config from the new shared global config directory.
internal/components/engram/inject_test.go Renames test and updates expected MCP config output path to the shared global location.
internal/agents/antigravity/adapter_test.go Updates adapter path tests to expect the global MCP config path.
internal/agents/antigravity/adapter.go Changes MCPConfigPath implementation to always point at the shared global config file.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 571 to 574
cliMCPPath := filepath.Join(home, ".gemini", "config", "mcp_config.json")
content, err := os.ReadFile(cliMCPPath)
if err != nil {
t.Fatalf("ReadFile(%q) error = %v", cliMCPPath, err)
Comment thread internal/components/golden_test.go Outdated
Comment on lines +899 to +900
// MCP config written to ~/.gemini/config/mcp_config.json.
mcpJSON := readTestFile(t, filepath.Join(home, ".gemini", "config", "mcp_config.json"))
Comment thread internal/agents/antigravity/adapter.go Outdated
Comment on lines +108 to +109
// Antigravity uses a shared global config for MCP across CLI, Desktop, and IDE.
return filepath.Join(homeDir, ".gemini", "config", "mcp_config.json")

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@internal/components/engram/inject_test.go`:
- Line 571: The variable name cliMCPPath is misleading since the MCP config is
now stored in a global/shared location rather than a CLI-specific directory.
Rename the cliMCPPath variable to globalMCPPath (or mcpConfigPath) to accurately
reflect its purpose, and update all references to this variable throughout the
test file to maintain consistency.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: b39ab65d-ac1d-4de8-ae2c-2ed325d12f61

📥 Commits

Reviewing files that changed from the base of the PR and between c9e2ad6 and 6364fbf.

📒 Files selected for processing (4)
  • internal/agents/antigravity/adapter.go
  • internal/agents/antigravity/adapter_test.go
  • internal/components/engram/inject_test.go
  • internal/components/golden_test.go

Comment thread internal/components/engram/inject_test.go Outdated
@moferrin

Copy link
Copy Markdown
Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 17, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copilot AI review requested due to automatic review settings June 22, 2026 15:09

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

Comment thread internal/agents/antigravity/adapter.go Outdated
Comment on lines +12 to +18
// GlobalMCPConfigDir is the directory path relative to $HOME where Antigravity
// stores its shared MCP configuration. Exported so tests can build paths
// without duplicating magic strings.
var GlobalMCPConfigDir = filepath.Join(".gemini", "config")

// GlobalMCPConfigFile is the filename used for the shared MCP configuration.
const GlobalMCPConfigFile = "mcp_config.json"
Comment on lines 115 to 118
func (a *Adapter) MCPConfigPath(homeDir string, _ string) string {
return filepath.Join(a.antigravityVariantDir(homeDir), "mcp_config.json")
// Antigravity uses a shared global config for MCP across CLI, Desktop, and IDE.
return filepath.Join(homeDir, GlobalMCPConfigDir, GlobalMCPConfigFile)
}
@moferrin

Copy link
Copy Markdown
Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 22, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copilot AI review requested due to automatic review settings June 24, 2026 20:51

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
internal/components/engram/inject_test.go (1)

571-581: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Assert that the retired CLI MCP path is not written.

This proves the new global file is written, but it would still pass if Inject also kept writing ~/.gemini/antigravity-cli/mcp_config.json, which is the path this PR is meant to retire. The negative guard later in the test targets a different legacy location.

🧪 Possible assertion
 	globalMCPPath := antigravity.GlobalMCPConfigPath(home)
 	content, err := os.ReadFile(globalMCPPath)
 	if err != nil {
 		t.Fatalf("ReadFile(%q) error = %v", globalMCPPath, err)
 	}
+	oldCLIPath := filepath.Join(home, ".gemini", "antigravity-cli", "mcp_config.json")
+	if _, err := os.Stat(oldCLIPath); !os.IsNotExist(err) {
+		t.Fatalf("legacy CLI MCP path %q should not be written for antigravity; stat err = %v", oldCLIPath, err)
+	}
 	text := string(content)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/components/engram/inject_test.go` around lines 571 - 581, The Inject
test currently verifies the new Antigravity global MCP config contents but does
not assert that the retired CLI MCP config path is no longer written. Update the
test around globalMCPPath in inject_test.go to also check the legacy Antigravity
CLI MCP location is absent after Inject runs, using the existing Inject flow and
the retired path symbol(s) already used elsewhere in the test to make sure the
migration fully stops writing the old file.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@internal/agents/antigravity/adapter_test.go`:
- Around line 37-49: The Windows fallback path in the Antigravity IDE setup is
currently only covered when APPDATA is empty, so the new home/AppData/Roaming
branch is not exercised on Windows builders where APPDATA is normally set.
Update the test around the runtime.GOOS switch in adapter_test.go to add a
Windows-only case that explicitly verifies the fallback behavior when APPDATA is
unset, using the existing ideDir construction logic and the Antigravity IDE path
handling to keep the branch covered.

---

Outside diff comments:
In `@internal/components/engram/inject_test.go`:
- Around line 571-581: The Inject test currently verifies the new Antigravity
global MCP config contents but does not assert that the retired CLI MCP config
path is no longer written. Update the test around globalMCPPath in
inject_test.go to also check the legacy Antigravity CLI MCP location is absent
after Inject runs, using the existing Inject flow and the retired path symbol(s)
already used elsewhere in the test to make sure the migration fully stops
writing the old file.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: df1d2fa6-aa08-44ed-b2fa-8e4cc1db6925

📥 Commits

Reviewing files that changed from the base of the PR and between 5ff2c5e and a5eb6ed.

📒 Files selected for processing (4)
  • internal/agents/antigravity/adapter.go
  • internal/agents/antigravity/adapter_test.go
  • internal/components/engram/inject.go
  • internal/components/engram/inject_test.go
💤 Files with no reviewable changes (1)
  • internal/components/engram/inject.go

Comment thread internal/agents/antigravity/adapter_test.go Outdated
Copilot AI review requested due to automatic review settings June 24, 2026 22:13

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@moferrin

Copy link
Copy Markdown
Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 24, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

config_scan.go hardcoded the Antigravity path to ~/.gemini/antigravity-cli, missing IDE and Desktop variants. Add antigravityConfigDir() helper that mirrors the adapter's variant resolution (IDE → Desktop → CLI fallback) without importing the agents package (import cycle). Marked as a TODO shim until the cycle is broken.
Copilot AI review requested due to automatic review settings July 9, 2026 19:39

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Antigravity variants install into ~/.gemini/antigravity-ide, ~/.gemini/antigravity, and ~/.gemini/antigravity-cli natively. This commit removes OS-specific APPDATA legacy checks that caused permission/fallback issues and prioritizes variants sequentially.

Additionally, it appends a '(shared global configuration)' suffix to mcp_config.json writes in the CLI report to increase visibility, and fixes an unrelated .exe flake in the beta engram installation test.
Copilot AI review requested due to automatic review settings July 9, 2026 21:57

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Copilot AI review requested due to automatic review settings July 9, 2026 22:14

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Copilot AI review requested due to automatic review settings July 9, 2026 22:20

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Copilot AI review requested due to automatic review settings July 9, 2026 22:24

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Copilot AI review requested due to automatic review settings July 9, 2026 22:27
@moferrin
moferrin force-pushed the fix/antigravity-mcp-config-path branch from 69a6229 to ed58d05 Compare July 9, 2026 22:27

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Copilot AI review requested due to automatic review settings July 9, 2026 22:30
@moferrin
moferrin force-pushed the fix/antigravity-mcp-config-path branch from ed58d05 to a12a74b Compare July 9, 2026 22:30

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Copilot AI review requested due to automatic review settings July 9, 2026 22:31
@moferrin
moferrin force-pushed the fix/antigravity-mcp-config-path branch from a12a74b to 016391c Compare July 9, 2026 22:31

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

…den tests

Also updates golden files that had mismatched expectations.
Copilot AI review requested due to automatic review settings July 9, 2026 22:35

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@moferrin

moferrin commented Jul 10, 2026

Copy link
Copy Markdown
Author

First of all, my bad on the %APPDATA% issue; it was a mistake on my end to assume they used native OS paths on Windows.

To be 100% sure this time, I installed all three Antigravity variants on my PC and validated their actual folders. Doing this, we also realized that the old fallback in main was broken: it looked for a folder named antigravity-desktop (which doesn't actually exist) and completely ignored the IDE. The actual isolated folders created are:

  1. ~/.gemini/antigravity-ide/
  2. ~/.gemini/antigravity/ (Desktop)
  3. ~/.gemini/antigravity-cli/

With this PR, we structurally fix the root issue: mcp_config.json correctly goes to the shared global path (~/.gemini/config/), while for everything else (skills, settings, and agent detection) we built a fallback that finally covers the three actual versions in this order: IDE > Desktop > CLI.

Does this priority order seem correct to you? If you think the order should be different, or if you believe it would be better to have a way to configure each variant independently, let me know and we can iterate on it. I think this structure covers all edge cases now, but let me know what you think.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type:bug Bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(antigravity): stabilize config injection paths across variants and enforce engram tool profile

3 participants